function Node(data) {
    this.data = data;
    this.previous = null;
    this.next = null;
}

function DoubleLinkList() {
    this.head = null;
    this.tail = null;
    this.numberOfValues = 0;
}

DoubleLinkList.prototype.add = function (data) {
    let node = new Node(data);
    if (!this.head) {
        //链表的头节点和尾节点
        this.head = node;
        this.tail = node;
    } else {
        node.previous = this.tail; //当前新增节点的previous指向链表原来的尾节点
        this.tail.next = node; //原来链表的尾节点的next指向当前新增节点
        this.tail = node; //将当前节点更新为链表的尾节点
    }

    this.numberOfValues++;
};
